"""
file: test_param.py
Author: 城下秋草
Date: 2024/12/24
Desc: 参数化支持
"""
import pytest


@pytest.fixture(params=["秋草","测试"])
def param(request):
    yield request.param*2

# def test_param(param):
#     print(param)

# pytestmark = (

@pytest.mark.parametrize("exp,result",[("3+2",5),
                                       ("6-3",3),
                                       ("4*2",10),
                                       ("9/3",3)],
                         ids=["add","sub","mul","div"],
                         scope="class")
class TestCalc:
    def test_eval(self,exp,result):
        assert eval(exp) == result

    def test_show(self,exp,result):
        print(exp, result)

@pytest.mark.parametrize("name",["秋草","qiucao","this is a test"])
@pytest.mark.parametrize("age",[16,20,"20"])
@pytest.mark.parametrize("score",[61,88,102])
def test_form(name, age, score):
    assert len(name) < 6 and age > 15 and 60 < score <= 100

@pytest.fixture
def square(request):
    return request.param**2

@pytest.fixture
def cube(request):
    return request.param**3

@pytest.mark.parametrize("square,cube",[(3,2)],indirect=["square"])
def test_math(square,cube):
    assert square == 9
    assert cube == 8